//
//  WelcomeViewController.swift
//  YueJian
//
//  Created by mac on 2017/10/19.
//  Copyright © 2017年 MapleStory. All rights reserved.
//

import UIKit

class WelcomeViewController: UIViewController {

    let Swidth = UIScreen.main.bounds.width
    let Sheight = UIScreen.main.bounds.height
    override func viewDidLoad() {
        super.viewDidLoad()

        let scroller = UIScrollView(frame: CGRect(x: 0, y: 0, width: Swidth, height: Sheight))
        scroller.contentSize = CGSize(width: Swidth*2, height: 0)
        scroller.showsHorizontalScrollIndicator = false
        scroller.isPagingEnabled = true
        scroller.isUserInteractionEnabled = true
        scroller.showsVerticalScrollIndicator = false
        scroller.translatesAutoresizingMaskIntoConstraints = false
        self.view.addSubview(scroller)
        for i in 0...1 {
            let imageView = UIImageView(frame: CGRect(x: CGFloat(i)*Swidth, y: 0, width: Swidth, height: Sheight))
            imageView.image = UIImage(named: "welcome\(i)")
            //            imageView.contentMode = .scaleToFill
            
            if i == 1 {
                let button = UIButton(frame: CGRect(x: 30, y: Sheight-60, width: Swidth-60, height: 50))
                button.addTarget(self, action: #selector(goLogin), for: UIControlEvents.touchUpInside)
                button.backgroundColor = UIColor.black
                button.setTitle("进入体验", for: UIControlState.normal)
                imageView.isUserInteractionEnabled = true
                imageView.addSubview(button)
            }
            
            scroller.addSubview(imageView)
        }
    }
    
    @objc func goLogin() {
        let ap = UIApplication.shared.delegate as! AppDelegate
        ap.window?.rootViewController = LoginViewController()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
